﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:System="clr-namespace:System;assembly=mscorlib"
                    xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase">

  <DataTemplate x:Key="DateiverweiseListViewTile">
    <Grid>
      <Grid.InputBindings>
        <MouseBinding MouseAction="LeftDoubleClick" Command="{Binding Path=OpenDateiCommand}"/>
      </Grid.InputBindings>
      <Grid.ToolTip>
        <ToolTip HasDropShadow="True">
          <TextBlock Text="{Binding Path=DateiverweisDateiname}"/>
        </ToolTip>
      </Grid.ToolTip>
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
      </Grid.RowDefinitions>
      <Image Grid.Row="0" Source="{Binding Path=DateiverweisBild}" HorizontalAlignment="Center"/>
      <Image Grid.Row="0" Source="{Binding Path=DateiverweisBildOverlay}" HorizontalAlignment="Center"/>
      <TextBlock Width="70" Grid.Row="1" Text="{Binding Path=DateiverweisDateinameOhnePfad}" 
                 FontSize="8" HorizontalAlignment="Center" TextWrapping="WrapWithOverflow"/>
    </Grid>
  </DataTemplate>

  <DataTemplate x:Key="FotoDragAdorner">
    <Border BorderBrush="Gray" BorderThickness="1" CornerRadius="2" Margin="1">
      <TextBlock>Foto entfernen</TextBlock>
    </Border>
  </DataTemplate>

  <DataTemplate x:Key="TooltipLineTemplate">
    <Grid>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="20"/>
        <ColumnDefinition Width="100"/>
        <ColumnDefinition Width="17"/>
        <ColumnDefinition Width="17"/>
      </Grid.ColumnDefinitions>
      <Label Background="{Binding Path=LerngruppenterminFarbe}" VerticalAlignment="Center" 
                   Padding="0" FontSize="10" Grid.Column="0" 
                   Content="{Binding Path=TerminStundenbereich}"/>
      <Label Padding="10,0,0,0" VerticalAlignment="Center" FontSize="10" 
                   Grid.Column="1" Content="{Binding Path=TerminBeschreibung}"/>
      <Button Grid.Column="2" Command="{Binding Path=EditLerngruppenterminCommand}">
        <Image Source="/SoftTeach;component/Images/Edit16.png"/>
      </Button>
      <Button Grid.Column="3" Command="{Binding Path=RemoveLerngruppenterminCommand}">
        <Image Source="/SoftTeach;component/Images/Remove16.png"/>
      </Button>
    </Grid>
  </DataTemplate>

  <DataTemplate x:Key="TagesplanTemplate">
    <DataTemplate.Resources>
    </DataTemplate.Resources>
    <Grid Background="{Binding Path=TagesplanKalenderfarbe}" ContextMenu="{Binding Path=TagesplanContextMenu}">
      <Grid.RowDefinitions>
        <RowDefinition Height="18"/>
      </Grid.RowDefinitions>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="17"/>
        <ColumnDefinition Width="20"/>
        <ColumnDefinition Width="*"/>
      </Grid.ColumnDefinitions>
      <Label HorizontalAlignment="Right" VerticalAlignment="Center" Padding="0" FontSize="12" Grid.Column="0" Content="{Binding Path=TagesplanTagDesMonats}" Margin="0,0,2,0"/>
      <Label Padding="0" VerticalAlignment="Center" FontSize="12" Grid.Column="1" Content="{Binding Path=TagesplanWochentag}"/>
      <Label Name="LabelBeschreibung" Padding="0" Margin="0" VerticalAlignment="Center" FontSize="12" Grid.Column="2" Content="{Binding Path=TagesplanBeschreibung}">
        <Label.Triggers>
          <EventTrigger RoutedEvent="UIElement.MouseLeftButtonDown">
            <BeginStoryboard>
              <Storyboard>
                <BooleanAnimationUsingKeyFrames Storyboard.TargetName="DetailPopup" Storyboard.TargetProperty="(Popup.IsOpen)">
                  <DiscreteBooleanKeyFrame KeyTime="00:00:00" Value="True"/>
                </BooleanAnimationUsingKeyFrames>
              </Storyboard>
            </BeginStoryboard>
          </EventTrigger>
        </Label.Triggers>
      </Label>
      <StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" x:Name="Buttons" Visibility="Hidden">
        <StackPanel Orientation="Horizontal" Visibility="Hidden" x:Name="EditButtons">
          <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Command="{Binding Path=Lerngruppentermine[0].EditLerngruppenterminCommand}" ToolTip="Stunde ändern">
            <Grid>
              <Image Source="/SoftTeach;component/Images/Edit16.png"/>
            </Grid>
          </Button>
          <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Command="{Binding Path=Lerngruppentermine[0].RemoveLerngruppenterminCommand}" ToolTip="Termin/Stunde löschen">
            <Grid>
              <Image Source="/SoftTeach;component/Images/Remove16.png"/>
            </Grid>
          </Button>
        </StackPanel>
        <StackPanel Orientation="Horizontal">
          <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Command="{Binding Path=AddStundeCommand}" ToolTip="Stunde anlegen">
            <Grid>
              <Image Source="/SoftTeach;component/Images/Stundenentwurf16.png"/>
              <Image Source="/SoftTeach;component/Images/AddOverlay16.png"/>
            </Grid>
          </Button>
          <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Command="{Binding Path=AddLerngruppenterminCommand}" ToolTip="Lerngruppentermin anlegen">
            <Grid>
              <Image Source="/SoftTeach;component/Images/Lerngruppentermin16.png"/>
              <Image Source="/SoftTeach;component/Images/AddOverlay16.png"/>
            </Grid>
          </Button>
        </StackPanel>
      </StackPanel>
      <Popup 
        x:Name="DetailPopup"
        PopupAnimation="Fade" 
        Placement="Center" 
        HorizontalOffset="80"
        AllowsTransparency="True" 
        StaysOpen="True">
        <Popup.Resources>
          <CollectionViewSource Source="{Binding Path=Lerngruppentermine}" x:Key="LerngruppentermineSorted">
            <CollectionViewSource.SortDescriptions>
              <scm:SortDescription PropertyName="TerminErsteUnterrichtsstunde"/>
            </CollectionViewSource.SortDescriptions>
          </CollectionViewSource>
        </Popup.Resources>
        <Popup.Child>
          <ListBox x:Name="TerminList" ItemsSource="{Binding Source={StaticResource LerngruppentermineSorted}}"
                                 ItemTemplate="{StaticResource TooltipLineTemplate}">
            <ListBox.Triggers>
              <EventTrigger RoutedEvent="UIElement.MouseLeftButtonDown">
                <BeginStoryboard>
                  <Storyboard>
                    <BooleanAnimationUsingKeyFrames Storyboard.TargetName="DetailPopup" Storyboard.TargetProperty="(Popup.IsOpen)">
                      <DiscreteBooleanKeyFrame KeyTime="00:00:00" Value="False"/>
                    </BooleanAnimationUsingKeyFrames>
                  </Storyboard>
                </BeginStoryboard>
              </EventTrigger>
              <EventTrigger RoutedEvent="UIElement.MouseLeave">
                <BeginStoryboard>
                  <Storyboard>
                    <BooleanAnimationUsingKeyFrames Storyboard.TargetName="DetailPopup" Storyboard.TargetProperty="(Popup.IsOpen)">
                      <DiscreteBooleanKeyFrame KeyTime="00:00:00" Value="False"/>
                    </BooleanAnimationUsingKeyFrames>
                  </Storyboard>
                </BeginStoryboard>
              </EventTrigger>
            </ListBox.Triggers>
          </ListBox>
          <!--<Border x:Name="PopupBorder" Background="White" BorderThickness="1" BorderBrush="CadetBlue" CornerRadius="5" Padding="5">
            <Border.Triggers>
              <EventTrigger RoutedEvent="UIElement.MouseLeftButtonDown">
                <BeginStoryboard>
                  <Storyboard>
                    <BooleanAnimationUsingKeyFrames Storyboard.TargetName="DetailPopup" Storyboard.TargetProperty="(Popup.IsOpen)">
                      <DiscreteBooleanKeyFrame KeyTime="00:00:00" Value="False"/>
                    </BooleanAnimationUsingKeyFrames>
                  </Storyboard>
                </BeginStoryboard>
              </EventTrigger>
              <EventTrigger RoutedEvent="UIElement.MouseLeave">
                <BeginStoryboard>
                  <Storyboard>
                    <BooleanAnimationUsingKeyFrames Storyboard.TargetName="DetailPopup" Storyboard.TargetProperty="(Popup.IsOpen)">
                      <DiscreteBooleanKeyFrame KeyTime="00:00:00" Value="False"/>
                    </BooleanAnimationUsingKeyFrames>
                  </Storyboard>
                </BeginStoryboard>
              </EventTrigger>
            </Border.Triggers>
            <HeaderedContentControl Header="{Binding Path=TagesplanTooltipTitle}">
              <ListBox ItemsSource="{Binding Source={StaticResource LerngruppentermineSorted}}"
                                 ItemTemplate="{StaticResource TooltipLineTemplate}" />
            </HeaderedContentControl>
          </Border>-->
        </Popup.Child>
      </Popup>
    </Grid>
    <DataTemplate.Triggers>
      <DataTrigger Binding="{Binding Path=KeineLerngruppentermine}">
        <DataTrigger.Value>
          <System:Boolean>true</System:Boolean>
        </DataTrigger.Value>
        <Setter TargetName="TerminList" Property="Visibility" Value="Hidden"/>
        <Setter TargetName="EditButtons" Property="Visibility" Value="Hidden"/>
      </DataTrigger>
      <DataTrigger Binding="{Binding Path=KeineLerngruppentermine}">
        <DataTrigger.Value>
          <System:Boolean>false</System:Boolean>
        </DataTrigger.Value>
        <Setter TargetName="TerminList" Property="Visibility" Value="Visible"/>
        <Setter TargetName="EditButtons" Property="Visibility" Value="Visible"/>
      </DataTrigger>
      <EventTrigger RoutedEvent="UIElement.MouseEnter">
        <BeginStoryboard>
          <Storyboard>
            <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="Buttons" Storyboard.TargetProperty="(UIElement.Visibility)">
              <DiscreteObjectKeyFrame KeyTime="00:00:00">
                <DiscreteObjectKeyFrame.Value>
                  <Visibility>Visible</Visibility>
                </DiscreteObjectKeyFrame.Value>
              </DiscreteObjectKeyFrame>
            </ObjectAnimationUsingKeyFrames>
          </Storyboard>
        </BeginStoryboard>
      </EventTrigger>
      <EventTrigger RoutedEvent="UIElement.MouseLeave">
        <BeginStoryboard>
          <Storyboard>
            <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="Buttons" Storyboard.TargetProperty="(UIElement.Visibility)">
              <DiscreteObjectKeyFrame KeyTime="00:00:00">
                <DiscreteObjectKeyFrame.Value>
                  <Visibility>Hidden</Visibility>
                </DiscreteObjectKeyFrame.Value>
              </DiscreteObjectKeyFrame>
            </ObjectAnimationUsingKeyFrames>
          </Storyboard>
        </BeginStoryboard>
      </EventTrigger>
    </DataTemplate.Triggers>
  </DataTemplate>

  <DataTemplate x:Key="WeekendTemplate">
    <Grid Background="{Binding Path=TagesplanKalenderfarbe}">
      <Grid.RowDefinitions>
        <RowDefinition Height="18"/>
        <!--<RowDefinition Height="2"/>-->
      </Grid.RowDefinitions>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="17"/>
        <ColumnDefinition Width="20"/>
        <ColumnDefinition Width="*"/>
      </Grid.ColumnDefinitions>
      <Label Padding="0" HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Column="0" FontSize="12" Content="{Binding Path=TagesplanTagDesMonats}" Margin="0,0,2,0"/>
      <Label Padding="0" VerticalAlignment="Center" Grid.Column="1" FontSize="12" Content="{Binding Path=TagesplanWochentag}"/>
      <Label Padding="0" VerticalAlignment="Center" Grid.Column="2" FontSize="12" Content="{Binding Path=TagesplanBeschreibung}"/>
      <!--<Line Grid.Row="1" Grid.ColumnSpan="3" Stroke="Black"/>-->
    </Grid>
  </DataTemplate>

  <DataTemplate x:Key="ErgebnisTemplate">
    <StackPanel >
      <TextBox Text="{Binding Ergebnisse[0].ErgebnisPunktzahl}" Background="Salmon"/>
    </StackPanel>
  </DataTemplate>

  <DataTemplate x:Key="StundenentwurfTile">
    <Grid >
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="25"/>
        <ColumnDefinition Width="150"/>
        <ColumnDefinition Width="350"/>
      </Grid.ColumnDefinitions>
      <Rectangle x:Name="ModulRahmen" Grid.Column="0" Fill="White" Stroke="Transparent"/>
      <Rectangle x:Name="NameRahmen" Grid.Column="1" Fill="White" Stroke="Transparent"/>
      <Rectangle x:Name="PhasenRahmen" Grid.Column="2" Fill="White" Stroke="Transparent"/>
      <StackPanel Grid.Column="0">
        <TextBlock Margin="3" Text="{Binding Path=Stundenentwurf.StundenentwurfModul.ModulKurzbezeichnung, Mode=OneWay}"/>
        <StackPanel Orientation="Horizontal">
          <TextBlock Text="{Binding Path=Stundenentwurf.StundenentwurfStundenzahl, Mode=OneWay}"/>
          <TextBlock>h</TextBlock>
        </StackPanel>
      </StackPanel>
      <StackPanel Grid.Column="1">
        <TextBlock Margin="3" Text="{Binding Path=Stundenentwurf.StundenentwurfStundenthema, Mode=OneWay}"/>
        <TextBlock Margin="3" Text="{Binding Path=TerminString, Mode=OneWay}"/>
      </StackPanel>
      <TextBlock Margin="3" Grid.Column="2" Text="{Binding Path=Stundenentwurf.StundenentwurfPhasenKurzform, Mode=OneWay}"/>
    </Grid>
    <DataTemplate.Triggers>
      <EventTrigger RoutedEvent="UIElement.MouseEnter">
        <BeginStoryboard>
          <Storyboard>
            <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="ModulRahmen" Storyboard.TargetProperty="(Rectangle.Fill)">
              <DiscreteObjectKeyFrame KeyTime="00:00:00">
                <DiscreteObjectKeyFrame.Value>
                  <SolidColorBrush>LightSeaGreen</SolidColorBrush>
                </DiscreteObjectKeyFrame.Value>
              </DiscreteObjectKeyFrame>
            </ObjectAnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="NameRahmen" Storyboard.TargetProperty="(Rectangle.Fill)">
              <DiscreteObjectKeyFrame KeyTime="00:00:00">
                <DiscreteObjectKeyFrame.Value>
                  <SolidColorBrush>LightSeaGreen</SolidColorBrush>
                </DiscreteObjectKeyFrame.Value>
              </DiscreteObjectKeyFrame>
            </ObjectAnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="PhasenRahmen" Storyboard.TargetProperty="(Rectangle.Fill)">
              <DiscreteObjectKeyFrame KeyTime="00:00:00">
                <DiscreteObjectKeyFrame.Value>
                  <SolidColorBrush>LightSeaGreen</SolidColorBrush>
                </DiscreteObjectKeyFrame.Value>
              </DiscreteObjectKeyFrame>
            </ObjectAnimationUsingKeyFrames>
          </Storyboard>
        </BeginStoryboard>
      </EventTrigger>
      <EventTrigger RoutedEvent="UIElement.MouseLeave">
        <BeginStoryboard>
          <Storyboard>
            <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="ModulRahmen" Storyboard.TargetProperty="(Rectangle.Fill)">
              <DiscreteObjectKeyFrame KeyTime="00:00:00">
                <DiscreteObjectKeyFrame.Value>
                  <SolidColorBrush>White</SolidColorBrush>
                </DiscreteObjectKeyFrame.Value>
              </DiscreteObjectKeyFrame>
            </ObjectAnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="NameRahmen" Storyboard.TargetProperty="(Rectangle.Fill)">
              <DiscreteObjectKeyFrame KeyTime="00:00:00">
                <DiscreteObjectKeyFrame.Value>
                  <SolidColorBrush>White</SolidColorBrush>
                </DiscreteObjectKeyFrame.Value>
              </DiscreteObjectKeyFrame>
            </ObjectAnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="PhasenRahmen" Storyboard.TargetProperty="(Rectangle.Fill)">
              <DiscreteObjectKeyFrame KeyTime="00:00:00">
                <DiscreteObjectKeyFrame.Value>
                  <SolidColorBrush>White</SolidColorBrush>
                </DiscreteObjectKeyFrame.Value>
              </DiscreteObjectKeyFrame>
            </ObjectAnimationUsingKeyFrames>
          </Storyboard>
        </BeginStoryboard>
      </EventTrigger>
    </DataTemplate.Triggers>

  </DataTemplate>

</ResourceDictionary>